{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "乐学偶得版权所有 lexueoude.com 公众号：乐学Fintech"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#include<stdio.h>\n",
    "\n",
    "int main(void)\n",
    "{\n",
    "    \n",
    "    //printf(Control-String(控制下的字符串)，variable_1,variable_2......)\n",
    "  \n",
    "    return 0;\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Control-String(控制下的字符串):\n",
    "\n",
    "printf(\"I am %(s/f) \\n\")\n",
    "%占位（指定某种转换的格式进行输出）\n",
    "\n",
    "\"I am\" is literal characters(你打的什么，就会显示什么/字面意义上) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "昨天的股票上涨了8%\n"
     ]
    }
   ],
   "source": [
    "#include<stdio.h>\n",
    "\n",
    "int main(void)\n",
    "{\n",
    "    int num =8;\n",
    "    \n",
    "    printf(\"昨天的股票上涨了%d%%\\n\",num);\n",
    "  \n",
    "    return 0;\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "通过Modifier对我们的格式输出进行变形，比如说我们可以进行排版操作："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99999\n",
      "99999\n",
      "     99999\n",
      "99999     *\n"
     ]
    }
   ],
   "source": [
    "#include<stdio.h>\n",
    "#define NUM 99999\n",
    "\n",
    "\n",
    "int main(void)\n",
    "{\n",
    "    printf(\"%d\\n\",NUM);\n",
    "    printf(\"%3d\\n\",NUM);\n",
    "    printf(\"%10d\\n\",NUM);\n",
    "    printf(\"%-10d*\\n\",NUM);\n",
    "  \n",
    "    return 0;\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8888.880000\n",
      "8.888880e+03\n",
      "8888.9\n"
     ]
    }
   ],
   "source": [
    "#include<stdio.h>\n",
    "\n",
    "\n",
    "int main(void)\n",
    "{\n",
    "    const double NUM = 8888.88;\n",
    "    \n",
    "    printf(\"%f\\n\",NUM);\n",
    "    printf(\"%e\\n\",NUM);\n",
    "    printf(\"%4.1f\\n\",NUM);\n",
    "  \n",
    "    return 0;\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "f F 0XF\n"
     ]
    }
   ],
   "source": [
    "#include<stdio.h>\n",
    "\n",
    "\n",
    "int main(void)\n",
    "{\n",
    "    \n",
    "    printf(\"%x %X %#X\\n\",15,15,15);\n",
    "   \n",
    "    return 0;\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C",
   "language": "c",
   "name": "c"
  },
  "language_info": {
   "file_extension": ".c",
   "mimetype": "text/plain",
   "name": "c"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
